﻿using OpenQA.Selenium.Firefox;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
using System;
using System.Collections.Generic;
using System.Text;
using OpenQA.Selenium.Interactions;

namespace seleniumLearn
{
    class testSelenium
    {

        IWebDriver driver;

        // AuthenticationFG.S_CODE

        public void mouseClick()
        {
            // 去除广告
           
            Actions action = new Actions(driver);
            action.DoubleClick(driver.FindElement(By.Name("AuthenticationFG.VERIFICATION_CODE")));
        }
        public void testInput()
        {
            driver = new FirefoxDriver();
            driver.Manage().Window.Maximize();
            driver.Navigate().GoToUrl("https://www.isacombank.com.vn");
            var webElement = driver.FindElement(By.Name("AuthenticationFG.VERIFICATION_CODE"));
            webElement.SendKeys("1233");
        }

        public void testCheckBoxClick()
        {
            //AuthenticationFG.TARGET_CHECKBOX
            mouseClick();
            var webElement = driver.FindElement(By.Name("AuthenticationFG.IS_MSIGN_LGIN"));
            // webElement.Click();
        }

        public void savePicture()
        {
           
            var webElement = driver.FindElement(By.Id("IMAGECAPTCHA"));
            var elementScreenshot = (webElement as ITakesScreenshot).GetScreenshot();
            elementScreenshot.SaveAsFile("X:\\C#\\selenium\\项目1\\xybankworkers\\screenshot_of_element.png");
        }
        public void init()
        {
            driver = new FirefoxDriver();
            driver.Manage().Window.Maximize();
            driver.Navigate().GoToUrl("https://www.isacombank.com.vn");

            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(600);
            /*WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            IWebElement firstResult = wait.Until(e => e.FindElement(By.Name("AuthenticationFG.VERIFICATION_CODE")));*/

            mouseClick();
        }
        
    }
}
